"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var ionic_angular_1 = require("ionic-angular");
var ionic_angular_2 = require("ionic-angular");
/**
 * Generated class for the DatePickerPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */
var DatePickerPage = (function () {
    function DatePickerPage(navCtrl, navParams) {
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.today = { year: 0, month: 0, day: 0, week: 0 };
        this.week = [
            { name: '日', color: '#ff902d' },
            { name: '一', color: 'black' },
            { name: '二', color: 'black' },
            { name: '三', color: 'black' },
            { name: '四', color: 'black' },
            { name: '五', color: 'black' },
            { name: '六', color: '#ff902d' },
        ];
        this.month = [
            { name: '1月', value: 1 },
            { name: '2月', value: 2 },
            { name: '3月', value: 3 },
            { name: '4月', value: 4 },
            { name: '5月', value: 5 },
            { name: '6月', value: 6 },
            { name: '7月', value: 7 },
            { name: '8月', value: 8 },
            { name: '9月', value: 9 },
            { name: '10月', value: 10 },
            { name: '11月', value: 11 },
            { name: '12月', value: 12 },
        ];
        this.days = [];
        this.callBack = this.navParams.get("callback");
        var myDate = new Date();
        this.today.year = myDate.getFullYear();
        this.today.day = myDate.getDate();
        this.today.month = (myDate.getMonth() + 1);
        this.today.week = myDate.getDay();
        console.log(this.today.year + "年" + this.today.month + "月" + this.today.day + "日");
        for (var _i = 0, _a = this.month; _i < _a.length; _i++) {
            var item = _a[_i];
            var dayCount = this.getDays(this.today.year, item.value);
            var temp = { days: [] };
            var weekTemp = new Date(this.today.year, item.value - 1, 1).getDay();
            for (var i = 0; i < weekTemp; i++) {
                temp.days.push({ name: '', price: '' });
            }
            for (var i = 0; i < dayCount; i++) {
                temp.days.push({ name: (i + 1).toString(), price: '' });
            }
            this.days.push(temp);
        }
        console.log(this.days);
    }
    DatePickerPage.prototype.ionViewDidLoad = function () {
        console.log('ionViewDidLoad DatePickerPage');
        this.setBackButtonAction();
        document.getElementById(this.today.year + '|' + this.today.month + '|' + this.today.day).innerHTML = '今天';
    };
    DatePickerPage.prototype.getDays = function (year, month) {
        var d = new Date(year, month, 0);
        console.log(d.getDate());
        return d.getDate();
    };
    DatePickerPage.prototype.chooseDate = function (year, month, day, $event) {
        var _this = this;
        if (day && day.trim() !== '') {
            console.log($event.target);
            $event.target.style = 'color:white;background:#66ccff;';
            this.callBack({ year: year, month: month, day: day }).then(function () {
                _this.navCtrl.pop();
            });
        }
    };
    DatePickerPage.prototype.setBackButtonAction = function () {
        var _this = this;
        this.navBar.backButtonClick = function () {
            console.log("回调");
            _this.callBack({}).then(function () { _this.navCtrl.pop(); });
        };
    };
    __decorate([
        core_1.ViewChild(ionic_angular_2.Navbar)
    ], DatePickerPage.prototype, "navBar", void 0);
    DatePickerPage = __decorate([
        ionic_angular_1.IonicPage(),
        core_1.Component({
            selector: 'page-date-picker',
            templateUrl: 'date-picker.html',
        })
    ], DatePickerPage);
    return DatePickerPage;
}());
exports.DatePickerPage = DatePickerPage;
